package besta.moon.command;

import besta.moon.statement.MoonStatement;
import besta.moon.MoonConnection;
import besta.moon.MoonLogger;
import besta.moon.engine.selector.result.TableViewResult;

public class CommandDelete extends CommandSelect {

    public CommandDelete(MoonLogger log) {
        super(log);
    }

    @Override
    public void executeImpl(MoonConnection con, MoonStatement st) throws Exception {
        compile(con);
        TableViewResult result = TableViewResult.getTableViewResult(from);

        updateCount = 0;
        from.execute();
        while (next()) {
            result.deleteRow();
            updateCount++;
        }
    }

}
